package win.smartown.app;

import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.widget.TextView;

import win.smartown.app.base.SuperActivity;
import win.smartown.app.util.JumpUtil;
import win.smartown.app.weather.WeatherActivity;

/**
 * Created by smartown on 2017/4/12 14:02.
 * Desc:欢迎页
 */
public class WelcomeActivity extends SuperActivity {

    private int seconds = 1;
    private Handler handler = new Handler();

    private TextView timerTextView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        timerTextView = findView(R.id.welcome_timer);
        countDown();
    }

    private void countDown() {
        timerTextView.setText(seconds + "");
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                seconds--;
                if (seconds <= 0) {
                    JumpUtil.startActivity(WelcomeActivity.this, WeatherActivity.class, getResources().getString(R.string.app_name));
                    finish();
                } else {
                    countDown();
                }
            }
        }, 1000);
    }

}
